package com.txhy.certificatechain.ui.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/*
 * -----------------------------------------------------------------
 * Copyright (C) 2018-2030, by your company, All rights reserved.
 * -----------------------------------------------------------------
 * 文    件: CustomViewPager.java
 * 作    者: 侯建军
 * 版    权: 1.0.0
 * 描    述: 滑动部件
 * 创建时间: 2018/9/19 16:42
 * 更新时间：2018/9/19 16:42
 * -----------------------------------------------------------------
 * 2018/9/19 16:42: 创建 CustomViewPager.java (侯建军);
 * -----------------------------------------------------------------
 */
public class CustomViewPager extends ViewPager {
    private boolean result = false;
    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomViewPager(Context context) {
        super(context);
    }

    //去除页面切换时的滑动翻页效果
    @Override
    public void setCurrentItem(int item, boolean smoothScroll) {
        super.setCurrentItem(item, smoothScroll);
    }

    @Override
    public void setCurrentItem(int item) {
        super.setCurrentItem(item, false);
    }
    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {
        if (result)
            return super.onInterceptTouchEvent(arg0);
        else
            return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent arg0) {
        if (result)
            return super.onTouchEvent(arg0);
        else
            return false;
    }
}